package com.codejam.enums.demo.enums;

import lombok.Getter;


/**
 * MQ名称
 */
public enum WeekEnum implements IEnum{

    MONDAY(10, "星期一"),
    TUESDAY(20, "星期2"),
    WEDNESDAY(30, "星期3"),

    ;


    @Getter
    private int code;

    @Getter
    private String desc;

    WeekEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    static <E extends Enum<?> & IEnum> E valueOf(Class<E> enumClass, Integer code) {
        E[] enumConstants = enumClass.getEnumConstants();
        for (E e : enumConstants) {
            Integer tmpCode = e.getCode();
            if (code.equals(tmpCode))
                return e;
        }

        return null;
    }
}
